package practiceTest.chap03;

import chap03.BubbleSort.ArrayBub;
import chap03.InsertSort.ArrayIns;
import chap03.SelectSort.ArraySel;

import java.util.Date;

/**
 * Created by root on 2017/7/12.
 * 冒泡排序：逆序比随机快
 */
public class test2 {
    public static void main(String[] args){
        int maxSize = 1000;
        ArrayBub arr = new ArrayBub(maxSize);
        for (int j=maxSize-1;j>=0;j--) {
            arr.insert(j);
        }
        Date startTime = new Date();
        arr.bubbleSort();
        Date endTime = new Date();
        long time = endTime.getTime() - startTime.getTime();
        System.out.println("bubblesort time is " + time/1000 + " S");
        System.out.println("bubblesort time is " + time + " S");

        ArraySel arr1 = new ArraySel(maxSize);
        for (int j=maxSize-1;j>=0;j--) {
            arr1.insert(j);
        }
        Date startTime1 = new Date();
        arr1.selectSort();
        Date endTime1 = new Date();
        long time1 = endTime1.getTime() - startTime1.getTime();
        System.out.println("selectsort time is " + time1/1000 + " S");
        System.out.println("selectsort time is " + time1 + " S");

        ArrayIns arr2 = new ArrayIns(maxSize);
        for (int j=maxSize-1;j>=0;j--) {
            arr2.insert(j);
        }
        Date startTime2 = new Date();
        arr2.InsertSortWhileNums();
        Date endTime2 = new Date();
        long time2 = endTime2.getTime() - startTime2.getTime();
        System.out.println("insertsort time is " + time2/1000 + " S");
        System.out.println("insertsort time is " + time2 + " S");
    }
}
